﻿namespace MsForgeReboot.Web.Controllers {
    #region Usings

    using System.Web.Mvc;

    using MsForgeReboot.Framework.Interfaces;

    #endregion

    /// <summary>
    /// The cms controller.
    /// </summary>
    public class CmsController : Controller {
        // GET: /Cms/
        #region Fields

        /// <summary>
        /// The service.
        /// </summary>
        private readonly ICmsService service;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="CmsController"/> class.
        /// </summary>
        /// <param name="service">
        /// The service.
        /// </param>
        public CmsController(ICmsService service) {
            this.service = service;
        }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The index.
        /// </summary>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult Index() {
            return this.View();
        }

        /// <summary>
        /// The menu.
        /// </summary>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult Menu() {
            var result = this.service.GetSections();
            return this.PartialView("Menu", result);
        }

        /// <summary>
        /// The page.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult Page(string urlPointer) {
            var page = this.service.GetPageByUrlPointer(urlPointer);
            return this.View("Page", page);
        }

        #endregion
    }
}